﻿<Window x:Class="StackHash.ScriptAddEdit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vcs="clr-namespace:StackHash.ValueConverters"
    Title="ScriptAddEdit" Height="500" MinHeight="500" Width="450" MinWidth="450" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Icon="/StackHash;component/StackHash.ico" Loaded="Window_Loaded" Closed="Window_Closed">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MasterResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="Help" x:Name="commandBindingHelp" Executed="commandBindingHelp_Executed" />
    </Window.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        
        <Label Margin="7" Target="{Binding ElementName=textScriptName}">_Script Name:</Label>
        <TextBox Margin="10" Grid.Column="1" Name="textScriptName" MaxLength="255" IsEnabled="{Binding CanEdit}" Text="{Binding ScriptName, ValidatesOnDataErrors=True, Mode=TwoWay}" ToolTip="{Binding ElementName=textScriptName, Path=(Validation.Errors)[0].ErrorContent}" /> <!-- MaxLength is MaxPath less room for an extension -->

        <Label Margin="7,0,7,7" Grid.Row="1" Target="{Binding ElementName=comboBoxScriptType}">R_un Script On:</Label>
        <ComboBox Margin="10,0,10,10" Grid.Row="1" Grid.Column="1" Name="comboBoxScriptType" IsEnabled="{Binding CanEdit}" ItemsSource="{Binding DumpTypes}" SelectedItem="{Binding DumpType, Mode=TwoWay}" DisplayMemberPath="DisplayName" />
        
        <CheckBox Margin="10,0,10,10" Grid.Row="2" Grid.Column="1" IsEnabled="{Binding CanEdit}" IsChecked="{Binding RunAutomatically, Mode=TwoWay}">_Run on cabs automatically</CheckBox>
        
        <TextBlock Margin="10" Grid.Row="3" Grid.ColumnSpan="2" TextWrapping="Wrap">StackHash can store a comment for each script line. Just enter * before the comment (i.e. "<Span FontFamily="Courier New">!analyze -v * Run Analyze</Span>").
        </TextBlock>
        
        <TextBox Margin="10,0,10,10" Grid.Row="4" Grid.ColumnSpan="2" AcceptsReturn="True" Name="textScript" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" FontFamily="Courier New" IsEnabled="{Binding CanEdit}" Text="{Binding Script, ValidatesOnDataErrors=True, Mode=TwoWay}" ToolTip="{Binding ElementName=textScript, Path=(Validation.Errors)[0].ErrorContent}" />

        <Border Grid.Row="5" Grid.ColumnSpan="2" Style="{StaticResource ButtonBorder}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                
                <Button Margin="10" Command="Help">_Help</Button>

                <StackPanel Margin="7" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Margin="3" Name="buttonOK" IsDefault="True" Click="buttonOK_Click">OK</Button>
                    <Button Margin="3" Name="buttonCancel" IsCancel="True">Cancel</Button>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Window>
